<template>
  <!-- 头部部分 -->
  <header class="header">
    <h1>todos</h1>
    <input
      class="new-todo"
      placeholder="请输入任务名称"
      autofocus
      @keyup.enter="addList"
      v-model.trim="name"
    />
  </header>
</template>

<script>
export default {
  data() {
    return {
      name: '',
    };
  },
  methods: {
    addList() {
      if (!this.name) return alert("输入不能为空");
      this.$store.dispatch("list/add", {
        id: Date.now(),
        name:this.name,
        isDone: false,
      });
      this.name = "";
    },
  },
};
</script>

<style>
</style>
